package cn.strive.eams.room.controller;

import cn.strive.eams.base.response.JsonResult;
import cn.strive.eams.room.pojo.dto.RoomQuery;
import cn.strive.eams.room.pojo.dto.RoomSaveParam;
import cn.strive.eams.room.pojo.entity.Room;
import cn.strive.eams.room.pojo.vo.RoomVO;
import cn.strive.eams.room.service.RoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/room")
@Api(tags = "房间管理")
@Slf4j
public class RoomController {
    @Autowired
    RoomService roomService;

    @PostMapping("/save")
    @ApiOperation(value="保存教室")
    public JsonResult saveUser( RoomSaveParam roomSaveParam){
        log.debug("保存用户:RoomSaveParam={}",roomSaveParam);
        roomService.saveRoom(roomSaveParam);
        return JsonResult.ok();
    }
    @GetMapping("/select")
    public JsonResult selectAll(RoomQuery roomQuery){
        log.debug("查询教室:RoomQuery={}",roomQuery);
        List<RoomVO> list = roomService.selectAll(roomQuery);
        return JsonResult.ok(list);
    }
    @PutMapping("/update/status/{id}/{status}")
    @ApiOperation(value = "更新房间状态")
    public JsonResult updateStatus(@PathVariable Long id, @PathVariable String status){
        log.info("更新房间状态:id={},status={}", id, status);
        roomService.updateStatus(id, status);
        return JsonResult.ok();
    }
    @PostMapping("delete/{roomId}")
    public JsonResult deleteUser(@PathVariable Long roomId){
        log.debug("删除房间:roomId={}", roomId);
        roomService.deleteRoom(roomId);
        return JsonResult.ok();
    }
}
